use actix_web::{error::ErrorInternalServerError, web, Responder, Result};

use crate::{
    api_add, api_delete, api_edit,
    database::DbPool,
    route::form::post::{PostForm, WritePostForm},
    service::class,
};

pub fn config_admin_post(cfg: &mut web::ServiceConfig) {
    cfg.service(
        web::scope("/post")
            .route("/add", web::post().to(add_post))
            .route("/edit", web::post().to(edit_post))
            .route("/delete", web::post().to(delete_post)),
    );
}

api_add!(add_post, WritePostForm, class::post::write);
api_edit!(edit_post, PostForm, class::post::upd);
api_delete!(delete_post, PostForm, class::post::delete);
